package com.shuai.controller;


import com.shuai.model.vo.TaskVO;
import com.shuai.service.TaskService;
import com.shuai.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/task")
public class TaskController {
    @Autowired
    private TaskService taskService;

    /**
     * 查询/任务列表，根据子项目的Id
     * Param :subProjectId Y
     * pageIndex Y
     * pageSize Y
     * taskName N
     */
    @PostMapping(value = {"/taskList", "/searchTask"})
    public R taskList(@RequestBody Map<String, Object> params) {
        return this.taskService.taskList(params);
    }

    /**
     * 查询子当前子项目中的任务总比重
     * subProjectId
     */
    @PostMapping(value = "/allPropOfTask")
    public R allPropOfTask(@RequestBody TaskVO vo) {
        return this.taskService.allPropOfTask(vo);
    }

    /**
     * taskName
     * timeLimit
     * startTime
     * entTime
     * prop
     * subProjectId
     * managerId
     */
    @PostMapping(value = "/addTask")
    public R addTask(@RequestBody TaskVO vo) {
        return this.taskService.addTask(vo);
    }

    /**
     * 修改我的任务进度
     * taskId Y
     * taskCompletion Y
     * subProjectId 该任务的子项目Id  Y
     * projectId 该任务所在子项目的项目Id  Y
     */
    @PostMapping(value = "/updateTaskCompletion")
    public R updateTaskCompletion(@RequestBody Map<String, Object> params) {
        return this.taskService.updateTaskCompletion(params);
    }

    /**
     * 修改任务的其他信息
     * taskName
     * startTime
     * endTime
     * timeLimit
     * managerId
     * taskId
     */
    @PostMapping(value = "/updateTask")
    public R updateTask(@RequestBody TaskVO vo) {
        return this.taskService.updateTask(vo);
    }

    @PostMapping(value = "delTask")
    public R delTask(@RequestBody TaskVO vo) {
        return this.taskService.delTask(vo);
    }

}
